import { ecs } from "db://oops-framework/libs/ecs/ECS";
import { EquipModelComp } from "./model/EquipModelComp";
import { EquipUpgradeComp, EquipUpgradeSystem } from "./bll/EquipUpgrade";
import { EquipUpgradeCheckComp } from "./bll/EquipUpgradeCheck";
import { EquipModelLevelComp } from "./model/EquipModelLevelComp";
import { Role } from "../role/Role";
import { EquipWearComp, EquipWearSystem } from "./bll/EquipWear";
import { EquipUnwieldSystem } from "./bll/EquipUnwield";

/** 
 * 装备模块 
 * 1、装备基本信息
 * 2、装备技能
 * 3、装备外观
 * 4、装备升阶
 * 5、装备强化
 * 6、套装效果
 */
@ecs.register(`Equip`)
export class Equip extends ecs.Entity {
    EquipModel!: EquipModelComp;
    EquipModelLevel!: EquipModelLevelComp;

    // 业务层
    EquipUpgrade!: EquipUpgradeComp;              // 升级
    EquipUpgradeCheck!: EquipUpgradeCheckComp;    // 检查升级
    /** 实始添加的数据层组件 */
    protected init() {
        this.addComponents<ecs.Comp>(
            EquipModelComp,
            EquipModelLevelComp,
            EquipUpgradeCheckComp,
        )
    }
    /** 设置默认等级 */
    setLevel(lv: number = 0) {
        var eu = this.add(EquipUpgradeComp);
        eu.lv = lv;
        eu.type = 1;
    }
    /** 穿装备 */
    wear(role: Role) {
        this.add(EquipWearComp).role = role;
    }
    /** 模块资源释放 */
    destroy() {
        // 注: 自定义释放逻辑，视图层实现 ecs.IComp 接口的 ecs 组件需要手动释放
        super.destroy();
    }
}
export class EcsEquipSystem extends ecs.System {
    constructor() {
        super();

         this.add(new EquipWearSystem());
         this.add(new EquipUnwieldSystem());
         this.add(new EquipUpgradeSystem());
    }
}